package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class Entity 
{
protected int x,y,dx,dy,w,h;
protected double dx2=10.0, dy2=10.0;
protected StateImageLibrary imgs;
public Entity(int startx, int starty, String filename)
{
	imgs = new StateImageLibrary();
	x = startx;
	y = starty;
	dx = 0;
	dy = 0;
	addImage(filename);
}

public int getx()
{
	return x;
}

public int gety()
{
	return y;
}

public void addImage(String filename)
{
	imgs.addImage(filename);
}

public Image getImage()
{
	return imgs.getImage();
}

public void setdx(int dxx)
{
	dx = dxx;
}

public void setdy(int dyy)
{
	dy = dyy;
}

public void  move()
{
	if (dx != 0)
		x += dx;
	if (dy != 0)
		y += dy;
}

public double distance(int x1, int x2, int y1, int y2)
{
	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

public boolean collision(Entity e, double mapx)
{
	if (distance(e.getx()-(int)mapx, x, e.gety(), y) < 20) {
		System.out.println("collision");	
		return true;
	}
	else
		return false;
}

public int getdx()
{
	return dx;
}

public int getdy()
{
	return dy;
}

public double getdx2()
{
	return dx2;
}

public double getdy2()
{
	return dy2;
}

};
